<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<script>
    const zhanFileUrl = 'http://iwenwiki.com/api/vue3-image/create-vue3-2.png'
    const fileUrl = 'http://iwenwiki.com/api/vue3-image/create-vue3-10.png'
    function loadImage(fileUrl) {
        return new Promise(((resolve, reject) => {
            const img = new Image()
            img.src = fileUrl
            img.onload = () => {
                resolve('获取图片成功')
            }
            img.onerror = () => {
                loadImage(zhanFileUrl).then(data => {
                    console.log(data)
                }).catch(err => {
                    console.log(err)
                })
                reject('获取图片失败')
            }
            document.body.appendChild(img)
        }))
    }
    loadImage(fileUrl).then(data => {
        console.log(data)
    }).catch(err => {
        console.log(err)
    })
</script>
</body>
</html>
